package 作业2;

public class SevenAndMultipleOfSevenSum {

  public static void main(String[] args) {
    int sum = 0;
    int count = 0;

    for (int i = 0; i <= 1000; i++) {
      if (containsSeven(i) || isMultipleOfSeven(i)) {
        sum += i;
        count++;
      }
    }

    System.out.println("0～1000含有7或者是7倍数的整数之和：" + sum);
    System.out.println("符合条件的整数个数：" + count);
  }

  private static boolean containsSeven(int num) {
    while (num > 0) {
      int digit = num % 10;
      if (digit == 7) {
        return true;
      }
      num /= 10;
    }
    return false;
  }

  private static boolean isMultipleOfSeven(int num) {
    return num % 7 == 0;
  }
}
